package com.ykdl.member.kid.util;
/**
 * 数据移动的工具类，体温计 在使用
 */
public class ArrayTranslate
{
	public static void leftTranslate(String[] arr)
	{
		String tempCurr = null;
		String tempLast = arr[0];
		for (int i = arr.length - 1; i >= 0; i--)
		{
			tempCurr = arr[i];
			arr[i] = tempLast;
			tempLast = tempCurr;
		}
	}

	public static void rightTranslate(String[] arr)
	{
		String tempCurr = null;
		String tempLast = arr[arr.length - 1];
		for (int i = 0; i < arr.length; i++)
		{
			tempCurr = arr[i];
			arr[i] = tempLast;
			tempLast = tempCurr;
		}
	}

	public static String getString(int year, int month, int day)
	{
		return year + "-" + month + "-" + day;
	}

	public static String addOnDay(String date)
	{
		String[] dates = date.split("-");
		int year = Integer.valueOf(dates[0]);
		int month = Integer.valueOf(dates[1]);
		int day = Integer.valueOf(dates[2]);

		day++;
		if (day > CalendarUtil.getMonthDay(year, month - 1))
		{
			month++;
			day = 1;
			if (month > 12)
			{
				year++;
				month = 1;
			}
		}
		String result = getString(year, month, day);
		return result;

	}

	public static String lessenOnDay(String date)
	{
		String[] dates = date.split("-");
		int year = Integer.valueOf(dates[0]);
		int month = Integer.valueOf(dates[1]);
		int day = Integer.valueOf(dates[2]);

		day--;
		if (day < 1)
		{
			month--;
			if (month < 1)
			{
				year--;
				month = 12;
			}
			day = CalendarUtil.getMonthDay(year, month - 1);
		}
		String result = getString(year, month, day);
		return result;
	}

	public static String addOnWeek(String date)
	{
		String[] dates = date.split("-");
		int year = Integer.valueOf(dates[0]);
		int month = Integer.valueOf(dates[1]);
		int day = Integer.valueOf(dates[2]);

		day += 7;
		if (day > CalendarUtil.getMonthDay(year, month - 1))
		{
			month++;
			day = day - CalendarUtil.getMonthDay(year, month - 2);
			if (month > 12)
			{
				year++;
				month = 1;
			}
		}
		String result = getString(year, month, day);
		return result;

	}

	public static String lessenOnWeek(String date)
	{
		String[] dates = date.split("-");
		int year = Integer.valueOf(dates[0]);
		int month = Integer.valueOf(dates[1]);
		int day = Integer.valueOf(dates[2]);

		day -= 7;
		if (day < 1)
		{
			month--;
			if (month < 1)
			{
				year--;
				month = 12;
			}
			day += CalendarUtil.getMonthDay(year, month - 1);
		}
		String result = getString(year, month, day);
		return result;

	}
}
